package com.fishbone.file.config;

import com.fishbone.file.oss.AliOssClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName ObsAutoConfiguration
 * @Author huyaxi
 * @DATE 2020/6/28 12:08
 */
@Configuration
@EnableConfigurationProperties(OssProperties.class)
public class OssAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(AliOssClient.class)
    @ConditionalOnProperty(prefix = "oss",value = "enabled",havingValue = "true",matchIfMissing = true)
    AliOssClient ossClient(OssProperties properties) {
        return new AliOssClient(properties);
    }
}
